Memoization is an optimization technique for speeding up computer programs by caching the results of a function call. Memoization avoids having a function calculate the results when the results may be already stored in cache. In cases where the function call may be computationally expensive, memoization may drastically reduce computation time by only performing a specific calculation one time.
Memoization may add overhead to a program. The overhead may include testing a cache prior to executing a function, plus the overhead of storing results.
Memoization is possible when functions are ‘pure’. A pure function is one in which the function returns a consistent result given a set of inputs and is free from side effects. Side effects may be any change of state or other interaction with calling functions or the outside world.